package com.atguigu.study.bootredis.shardingjdbc.service.impl;

import com.atguigu.study.bootredis.shardingjdbc.dao.TOrderItem1Dao;
import com.atguigu.study.bootredis.shardingjdbc.entity.TOrderItem1;
import com.atguigu.study.bootredis.shardingjdbc.service.TOrderItem1Service;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TOrderItem1)表服务实现类
 *
 * @author makejava
 * @since 2021-01-09 20:22:40
 */
@Service("tOrderItem1Service")
public class TOrderItem1ServiceImpl implements TOrderItem1Service {
    @Resource
    private TOrderItem1Dao tOrderItem1Dao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TOrderItem1 queryById(String id) {
        return this.tOrderItem1Dao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TOrderItem1> queryAllByLimit(int offset, int limit) {
        return this.tOrderItem1Dao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tOrderItem1 实例对象
     * @return 实例对象
     */
    @Override
    public TOrderItem1 insert(TOrderItem1 tOrderItem1) {
        this.tOrderItem1Dao.insert(tOrderItem1);
        return tOrderItem1;
    }

    /**
     * 修改数据
     *
     * @param tOrderItem1 实例对象
     * @return 实例对象
     */
    @Override
    public TOrderItem1 update(TOrderItem1 tOrderItem1) {
        this.tOrderItem1Dao.update(tOrderItem1);
        return this.queryById(tOrderItem1.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.tOrderItem1Dao.deleteById(id) > 0;
    }
}